//
//  GJRNEventEmitter.m
//  xmgjAppFront
//
//  Created by Zeki on 2020/7/17.
//  Copyright © 2020 guojutech. All rights reserved.
//

#import "PayEventEmitter.h"

@implementation PayEventEmitter
RCT_EXPORT_MODULE()
- (NSArray<NSString *> *)supportedEvents{
  return @[@"PAY_RESULT"];
}
- (void)payBackStatonToJS:(NSNotification *)notifacation{
  dispatch_async(dispatch_get_main_queue(), ^{
    NSString *status = [notifacation.userInfo[@"status"] isEqualToString:@"1"] ? @"success" : @"fail";
    [self sendEventWithName:@"PAY_RESULT" body:@{@"result":status}];
  });
}

- (void)startObserving{
  
}

- (void)stopObserving{
  
}
- (instancetype)init
{
  self = [super init];
  if (self) {
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(payBackStatonToJS:) name:GJKPayResultNotification object:nil];
  }
  return self;
}
- (void)dealloc
{
  [[NSNotificationCenter defaultCenter] removeObserver:self name:GJKPayResultNotification object:nil];
  
}

@end
